package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sxm.yiwei.R;

import java.util.HashMap;
import java.util.List;

/**
 * Created by KuKa on 2017/7/3.
 * 急件要发 发货人列表
 */

public class HotSendLinkItemAdapter extends BaseAdapter {
    Context context;
    List<HashMap<String,String>> aa;
    public HotSendLinkItemAdapter(Context context, List<HashMap<String,String>> aa) {
        this.context= context;
        this.aa=aa;
    }

    @Override
    public int getCount() {
        return aa.size();
    }

    @Override
    public Object getItem(int position) {
        return aa.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.hotsend_linkitem,null);
            holder = new ViewHolder();
            holder.text_linkname = (TextView) view.findViewById(R.id.text_linkname);
            holder.text_linkphone = (TextView) view.findViewById(R.id.text_linkphone);
            holder.text_linkaddress = (TextView) view.findViewById(R.id.text_linkaddress);
            holder.linknumber = (TextView) view.findViewById(R.id.text_linknumber);
            view.setTag(holder);

        }else {
            view=convertView;
            holder = (ViewHolder) view.getTag();
        }

        holder.text_linkname.setText(aa.get(position).get("name"));
        holder.text_linkphone.setText(aa.get(position).get("phone"));
        holder.text_linkaddress.setText(aa.get(position).get("address"));
        holder.linknumber.setText("拼"+(position+1));
        return view;
    }

    class ViewHolder{
        TextView text_linkname,text_linkphone,text_linkaddress,linknumber;
    }
}
